#INCLUDE "PROTHEUS.CH"
#INCLUDE "APWEBEX.CH"
/*/{Protheus.doc} DTRWEB01

@descricao PAGINA DE LOGIN DO PORTAL

@author Peterson Scherwinski

@since 14/04/2014

/*/
User Function DTRWEB01
	Local cHtml	:= ""
	local oObj
	local cPagina	:= "DTRHTM01"//pagina a ser apresentada - login

	Web Extended Init cHtml// START "init"
	HTTPSESSION->USERLOGIN	:= {}
	HTTPSESSION->ALERT		:= ""
	
	if !empty(HTTPPOST->username).AND.!empty(HTTPPOST->password)
		//Validacao do usuario e senha
		oObj := WSDTRWEBSR():New()
		oObj:CTOKEN 		:= "DATAROUTEWEB"
		oObj:CUserName	:= HTTPPOST->username
		oObj:CUserPassword := HTTPPOST->password
		
		IF oObj:GETLOGIN()
			if len(oObj:OWSGETLOGINRESULT:OWSDADOSLOGIN)>0
				aAdd(HTTPSESSION->USERLOGIN,oObj:OWSGETLOGINRESULT:OWSDADOSLOGIN[1]:CFULLNAME)
				aAdd(HTTPSESSION->USERLOGIN,oObj:OWSGETLOGINRESULT:OWSDADOSLOGIN[1]:CUSERNAME)
				aAdd(HTTPSESSION->USERLOGIN,oObj:OWSGETLOGINRESULT:OWSDADOSLOGIN[1]:NTPACCESS)
				aAdd(HTTPSESSION->USERLOGIN,oObj:OWSGETLOGINRESULT:OWSDADOSLOGIN[1]:CCODRECUR)
				aAdd(HTTPSESSION->USERLOGIN,oObj:OWSGETLOGINRESULT:OWSDADOSLOGIN[1]:CSKIN)
				aAdd(HTTPSESSION->USERLOGIN,oObj:OWSGETLOGINRESULT:OWSDADOSLOGIN[1]:CAGENDA)
				//CARREGA PAGINA DO MENU
				IF HTTPSESSION->USERLOGIN[3] == 1
					cPagina	:= "DTRHTM02"
				else
					HTTPSESSION->ALERT		:= "Usuario sem acesso definido, avise o administrador"
				Endif
			else
				HTTPSESSION->ALERT		:= "Login sem informacoes, avise o administrador"
			endif
		else
			HTTPSESSION->ALERT		:= "Usuario ou senha invalidos!"
		endif
	endif
	
	//HTML DE LOGIN
	execInPage(cPagina)
	
	Web Extended End

return(cHtml)
